

package Pro;

import java.util.ArrayList;


public class checkvalied_table {
public static boolean check_6(int[] num, boolean dong, Object[][] table)
{
    boolean kq=false;
    boolean[] vali=new boolean[num.length];
    vali[0]=true;
    for (int i = 1; i < num.length; i++) {
        if(dong==true)
        {
        if(num[i]==num[i-1]+1)
        {
            vali[i]=true;
        }
        }else
        {
            if(num[i]==num[i-1]+6)
            {
                vali[i]=true;
            }
        }
    }
    //gan gia tri
    kq=true;
    for (boolean b : vali) {
        if(b==false)
        {
            kq=false;
        }
    }
    if(kq==false)
    {
        int begin=num[0];
        int end=num[num.length-1];
        boolean[] tempbboo=new boolean[(num[num.length-1]-num[0])+1];
        if(dong==true)
        {
            for (int i = begin, j=0; i<=end; i++, j++) {
                //Chuyen so so thanh dang bang
                int[] temp=convert.number_to_table(i, 6);
                if(table[temp[0]][temp[1]].equals(""))
                {
                    tempbboo[j]=false;
                }else
                {
                    tempbboo[j]=true;
                }
                System.out.println(i+" fdsfdsf "+tempbboo[j]);
            }
        }else
        {
            tempbboo=new boolean[((num[num.length-1]-num[0])/6)+1];
            for (int i = begin, j=0; i<=end; i=i+6, j++) {
                //Chuyen so so thanh dang bang
                int[] temp=convert.number_to_table(i, 6);
                System.out.println(i);
                if(table[temp[0]][temp[1]].equals(""))
                {
                    tempbboo[j]=false;
                }else
                {
                    tempbboo[j]=true;
                }
                System.out.println(i+" fdsfdsf "+tempbboo[j]);
            }
        }
        kq=true;
        System.out.println("=------------");
        for (int m = 0; m < tempbboo.length; m++) {
            if(tempbboo[m]==false)
            {
                kq=false;
            }
            System.out.println(tempbboo[m]);
        }
    }
    //check
    //Bat theo 3 ki tu
    if(dong==true)
    {
    if(((num[num.length-1]-num[0])+1)<3)
    {
        kq=false;
    }
    }else
    {
        if((((num[num.length-1]-num[0])/6)+1)<3)
    {
        kq=false;
    }
    }
    return kq;
}
public static boolean check_4(int[] num, boolean dong, Object[][] table)
{
    boolean kq=false;
    boolean[] vali=new boolean[num.length];
    vali[0]=true;
    for (int i = 1; i < num.length; i++) {
        if(dong==true)
        {
        if(num[i]==num[i-1]+1)
        {
            vali[i]=true;
        }
        }else
        {
            if(num[i]==num[i-1]+4)
            {
                vali[i]=true;
            }
        }
    }
    //gan gia tri
    kq=true;
    for (boolean b : vali) {
        if(b==false)
        {
            kq=false;
        }
    }
    if(kq==false)
    {
        int begin=num[0];
        int end=num[num.length-1];
        boolean[] tempbboo=new boolean[(num[num.length-1]-num[0])+1];
        if(dong==true)
        {
            for (int i = begin, j=0; i<=end; i++, j++) {
                //Chuyen so so thanh dang bang
                int[] temp=convert.number_to_table(i, 4);
                if(table[temp[0]][temp[1]].equals(""))
                {
                    tempbboo[j]=false;
                }else
                {
                    tempbboo[j]=true;
                }
                System.out.println(i+" fdsfdsf "+tempbboo[j]);
            }
        }else
        {
            tempbboo=new boolean[((num[num.length-1]-num[0])/4)+1];
            for (int i = begin, j=0; i<=end; i=i+4, j++) {
                //Chuyen so so thanh dang bang
                int[] temp=convert.number_to_table(i, 4);
                System.out.println(i);
                if(table[temp[0]][temp[1]].equals(""))
                {
                    tempbboo[j]=false;
                }else
                {
                    tempbboo[j]=true;
                }
                System.out.println(i+" fdsfdsf "+tempbboo[j]);
            }
        }
        kq=true;
        System.out.println("=------------");
        for (int m = 0; m < tempbboo.length; m++) {
            if(tempbboo[m]==false)
            {
                kq=false;
            }
            System.out.println(tempbboo[m]);
        }
    }
    //check
    //Bat theo 3 ki tu
    if(dong==true)
    {
    if(((num[num.length-1]-num[0])+1)<3)
    {
        kq=false;
    }
    }else
    {
        if((((num[num.length-1]-num[0])/4)+1)<3)
    {
        kq=false;
    }
    }
    return kq;
}
//get full of length return string0 is position, string1 is value
public static String[] getfulque(int[] num, boolean dong, Object[][] table, int type)
{
    String[] re=new String[2];
    if(type==6)
    {
        int begin=num[0];
        int end=num[num.length-1];
        String temp1="";
        String temp2="";
        if(dong==true)
        {
            for (int i = begin; i<=end; i++) {
                //Chuyen so so thanh dang bang
                int[] temp=convert.number_to_table(i, 6);
                temp1=temp1+i+"-";
                temp2=temp2+table[temp[0]][temp[1]];
            }
        }else
        {
            for (int i = begin; i<=end; i=i+6) {
                //Chuyen so so thanh dang bang
                int[] temp=convert.number_to_table(i, 6);
                temp1=temp1+i+"-";
                temp2=temp2+table[temp[0]][temp[1]];
            }
        }
        //
        re[0]=temp1;
        re[1]=temp2;
    }else
    {
        int begin=num[0];
        int end=num[num.length-1];
        String temp1="";
        String temp2="";
        if(dong==true)
        {
            for (int i = begin; i<=end; i++) {
                //Chuyen so so thanh dang bang
                int[] temp=convert.number_to_table(i, 4);
                temp1=temp1+i+"-";
                temp2=temp2+table[temp[0]][temp[1]];
            }
        }else
        {
            for (int i = begin; i<=end; i=i+4) {
                //Chuyen so so thanh dang bang
                int[] temp=convert.number_to_table(i, 4);
                temp1=temp1+i+"-";
                temp2=temp2+table[temp[0]][temp[1]];
            }
        }
        //
        re[0]=temp1;
        re[1]=temp2;
    }
    return re;
}
    public static void main(String[] args) {
           Object[][] vo=new Object[6][6];
           vo[0][0]="A";
           vo[1][0]="B";
           vo[2][0]="A";
           vo[3][0]="A";
           vo[4][0]="A";
           vo[5][0]="A";
           int[] num=new int[3];
           num[0]=1;
           num[1]=4;
           num[2]=5;
           //num[3]=4;
           getfulque(num, true, vo,6);
    }
}
